From 5714504a6fc7d8b0b47bbe3f3368b930ee82b44d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Florian=20M=C3=BCllner?= Date: Wed, 1 Oct 2025 20:19:14 +0200 Subject: [PATCH] messageList: Make media messages follow notification policy Unlike regular notifications, media messages are shown unconditionally for any active MPRIS player. In the past that was uncontroversial, but now that media messages are shown on the lock screen as well, there is a privacy concern. To address this, make media messages follow the notification policy of the corresponding app (if specified) or the general notification settings. Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/8600 Part-of: --- js/ui/messageList.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/js/ui/messageList.js b/js/ui/messageList.js index 265d7a3f9..ee4f7e258 100644 --- a/js/ui/messageList.js +++ b/js/ui/messageList.js @@ -793,6 +793,8 @@ class MediaMessage extends Message { this._player.next(); }); + Main.sessionMode.connectObject('updated', + () => this._applyPolicy(), this); this._player.connectObject('changed', this._update.bind(this), this); this._update(); } @@ -805,6 +807,12 @@ class MediaMessage extends Message { Main.panel.closeCalendar(); } + _applyPolicy() { + this.visible = + this._policy.enable && + (!Main.sessionMode.isLocked || this._policy.showInLockScreen); + } + _updateNavButton(button, sensitive) { button.reactive = sensitive; } @@ -832,6 +840,22 @@ class MediaMessage extends Message { this._updateNavButton(this._prevButton, this._player.canGoPrevious); this._updateNavButton(this._nextButton, this._player.canGoNext); + + const appId = this._player.app?.id.replace(/\.desktop$/, ''); + if (this._policy?.id !== appId) { + this._policy?.disconnectObject(this); + + this._policy = MessageTray.NotificationPolicy.newForApp(this._player.app); + + // Register notification source + this._policy.store(); + + this._policy.connectObject( + 'notify::enable', () => this._applyPolicy(), + 'notify::show-in-lock-screen', () => this._applyPolicy(), + this); + this._applyPolicy(); + } } }); -- 2.39.5